home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / pctj8411.arc / ELOCK.ASM < prev    next >
Assembly Source File  |  1986-09-14  |  4KB  |  150 lines

  1.     PAGE 55,132
  2. ;Program Name: ELOCK.ASM
  3. ;Author: William L. Colsher
  4. ;Date Written: May 19, 1984
  5. ;Purpose: This program provides the 3Com/EtherNet semaphore facility
  6. ;      to compiled BASIC programs.  Three services are provided:
  7. ;      1. Lock/Return - sets a semaphore and returns immediately
  8. ;      2. Lock/Wait - sets a semaphore, if unsuccessful, retry
  9. ;                     until timeout
  10. ;      3. Unlock - unlocks a locked semaphore
  11. ;
  12. ;Entry Points: LOCK, WAITLOCK, UNLOCK
  13. ;
  14. ;Calling Parameters: drive_id - integer, specifies EtherShare drive
  15. ;                    containing the data in use.  A:=1,
  16. ;                B:=2, etc.
  17. ;    
  18. ;             sem_name - character string, semaphore name
  19. ;                        to be used, must be 31 characters
  20. ;                or less in length and terminated with
  21. ;                a null, i.e.: CHR$(0)    
  22. ;
  23. ;             time_out - integer, the number of seconds to
  24. ;                wait while re-trying a lock/wait
  25. ;
  26. ;             error_cd - integer, error code returned by
  27. ;                EtherShare routine. Actual codes
  28. ;                are listed with functions.
  29. ;
  30. ;Calling Sequence: CALL LOCK (drive_id,sem_name,error_cd)
  31. ;           CALL WAITLOCK (drive_id,sem_name,time_out,error_cd)
  32. ;           CALL UNLOCK (drive_id,sem_name,error_cd)
  33. ;
  34.     ASSUME    CS:ELOCK
  35. ELOCK     SEGMENT    'CODE'
  36.     PUBLIC    LOCK
  37.     PUBLIC    UNLOCK
  38.     PUBLIC    WAITLOCK
  39.     
  40. LOCK    PROC    FAR
  41.  
  42. ;Entry point LOCK is used to attempt to LOCK a semaphore.
  43. ;
  44. ;Error codes returned are: 0 - operation successful
  45. ;               1 - semaphor already locked
  46. ;               2 - server not responding
  47. ;               3 - invalid semaphore name    
  48. ;               4 - semaphore list full
  49. ;               5 - invalid drive_id
  50. ;               6 - invalid net address
  51. ;               7 - not logged in
  52. ;               8 - write to network failed
  53. ;               9 - semaphore already locked by caller
  54.  
  55.     PUSH    BP        ;Save BP
  56.     MOV    BP,SP        ;point to param list
  57.     MOV    SI,[BP]+10    ;Get drive_id address
  58.     MOV    AX,[SI]        ;retrieve actual drive number
  59.     MOV    BX,[BP]+8    ;Get pointer to sem_name data
  60.     MOV    BX,2[BX]    ;Skip length and move address into BX
  61.     
  62.     MOV    AH,12h        ;LOCK function code in AH
  63.     MOV    SI,0        ;Use drive_id instead of net address
  64.     INT    60h        ;do it!
  65.  
  66.     MOV    SI,[BP]+6    ;get address of error_cd
  67.     MOV    AH,0        ;clear high byte of AX
  68.     MOV    [SI],AX        ;Give caller the return code
  69.  
  70.     POP    BP
  71.     RET    6
  72.  
  73. LOCK    ENDP
  74.  
  75. WAITLOCK PROC    FAR
  76.  
  77. ;Entry point WAITLOCK is used to attempt to lock a semaphore.  If the
  78. ;attempt is not successful, the EtherShare routine will retry
  79. ;the operation until it is successful or a timeout occurs.
  80. ;
  81. ;Error codes returned are: 0 - operation successful
  82. ;               1 - time out
  83. ;               2 - server not responding
  84. ;               3 - invalid semaphore name    
  85. ;               4 - semaphore list full
  86. ;               5 - invalid drive_id
  87. ;               6 - invalid net address
  88. ;               7 - not logged in
  89. ;               8 - write to network failed
  90. ;               9 - semaphore already locked by caller
  91.  
  92.     PUSH    BP        ;save BP
  93.     MOV    BP,SP        ;point to param list
  94.     MOV    SI,[BP]+12    ;Get drive_id address
  95.     MOV    AX,[SI]        ;retrieve actual drive number
  96.     MOV    BX,[BP]+10    ;Get pointer to sem_name data
  97.     MOV    BX,2[BX]    ;Skip length and move address into BX
  98.     MOV    SI,[BP]+8    ;get time_out address
  99.     MOV    DX,[SI]        ;get time_out value
  100.     
  101.     MOV    AH,11h        ;LOCK/WAIT function code in AH
  102.     MOV    SI,0        ;Use drive_id instead of net address
  103.     INT    60h        ;do it!
  104.  
  105.     MOV    SI,[BP]+6    ;get address of error_cd
  106.     MOV    AH,0        ;clear high byte of AX
  107.     MOV    [SI],AX        ;Give caller the return code
  108.  
  109.     POP    BP
  110.     RET    8
  111.  
  112. WAITLOCK ENDP
  113.  
  114. UNLOCK    PROC    FAR
  115.  
  116. ;Entry point UNLOCK is used to unlock a currently locked semaphore
  117. ;
  118. ;Error codes returned are: 0 - operation successful
  119. ;               1 - semaphore not locked
  120. ;               2 - server not responding
  121. ;               3 - invalid semaphore name    
  122. ;               4 - semaphore list full
  123. ;               5 - invalid drive_id
  124. ;               6 - invalid net address
  125. ;               7 - not logged in
  126. ;               8 - write to network failed
  127.  
  128.     PUSH    BP        ;Save BP
  129.     MOV    BP,SP        ;point to param list
  130.     MOV    SI,[BP]+10    ;Get drive_id address
  131.     MOV    AX,[SI]        ;retrieve actual drive number
  132.     MOV    BX,[BP]+8    ;Get pointer to sem_name data
  133.     MOV    BX,2[BX]    ;Skip length and move address into BX
  134.     
  135.     MOV    AH,13h        ;UNLOCK function code in AH
  136.     MOV    SI,0        ;Use drive_id instead of net address
  137.     INT    60h        ;do it!
  138.  
  139.     MOV    SI,[BP]+6    ;get address of error_cd
  140.     MOV    AH,0        ;clear high byte of AX
  141.     MOV    [SI],AX        ;Give caller the return code
  142.  
  143.     POP    BP
  144.     RET    6
  145.  
  146. UNLOCK    ENDP
  147.  
  148. ELOCK    ENDS
  149.     END
  150.